{Set Intersection}
const
  max = 1001;
  oo = 1000000000;
var
  a, b : array[0..max] of longint;
  n, m, s : integer;

procedure inp;
begin
  n := 0;
  repeat
    inc(n);
    read(a[n]);
  until a[n] = -1;
  dec(n);
  m := 0;
  repeat
    inc(m);
    read(b[m]);
  until b[m] = -1;
  dec(m);
end;

procedure swap(var u, v : longint);
var
  temp : longint;
begin
  temp := u;
  u := v;
  v := temp;
end;

procedure sorta(l, r : longint);
var
  i, j, k : longint;
begin
  if l >= r then exit;
  i := l;
  j := r;
  k := a[l+random(r-l+1)];
  repeat
    while a[i] < k do inc(i);
    while a[j] > k do dec(j);
    if i <= j then
    begin
      swap(a[i], a[j]);
      inc(i); dec(j);
    end;
  until i > j;
  sorta(i, r); sorta(l, j);
end;

procedure sortb(l, r : longint);
var
  i, j, k : longint;
begin
  if l >= r then exit;
  i := l;
  j := r;
  k := b[l+random(r-l+1)];
  repeat
    while b[i] < k do inc(i);
    while b[j] > k do dec(j);
    if i <= j then
    begin
      swap(b[i], b[j]);
      inc(i); dec(j);
    end;
  until i > j;
  sortb(i, r); sortb(l, j);
end;

procedure process;
var
  i, j : longint;
begin
  sorta(1, n);
  sortb(1, m);
  a[n+1] := oo;
  b[0] := 0;
  s := 0;
  j := 0;
  for i := 1 to n do
    if a[i] < a[i+1] then
    begin
      while (j < m) and (b[j+1] <= a[i]) do inc(j);
      if a[i] = b[j] then
      begin
        inc(s);
        write(a[i], ' ');
      end;
    end;
  if s = 0 then writeln('empty');
end;

begin
  inp;
  process;
end.